import { createBrowserRouter  } from 'react-router-dom';
/**
 *  require.context
 *  @params directory:表示检索的目录
 *  @params  useSubdirectories：表示是否检索子文件夹
 *  @params regExp:匹配文件的正则表达式,一般是文件名
 */
let routeList = [];
// 导入路由
function importAllRoute(r, routeList) {
  r.keys().forEach((key) => {
    // r(key) 翻译出来为 __webpack_require__('./index.jsx')
    routeList.push(...r(key).default);
  });
}
let webpackContextFun = require.context('./testRoute', false, /\.jsx$/)
importAllRoute(webpackContextFun,routeList);


const router = createBrowserRouter(routeList,{
  basename: "/my-app",
});

export { router };
